# -*- coding:utf-8 -*-
import os
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *


class ElementWidget(QWidget):

    def __init__(self,_title,_name,_pub_date,deleta_hour):
        super(ElementWidget, self).__init__()


        self.big_font = QFont('',15,64)
        self.litter_font = QFont('',9,55)
        self.main_layout = QVBoxLayout()
        self.title_label = QLabel(f'[{_title}]')
        self.title_label.setAlignment(Qt.AlignLeft)
        self.title_label.setFont(self.big_font)
        self.info_layout = QHBoxLayout()
        self.info_layout.setAlignment(Qt.AlignRight)
        self.info_layout.setSpacing(20)
        self.left_label = QLabel('剩余时间:')
        self.left_label.setFont(self.litter_font)
        self.left_hour = QLabel(f'{deleta_hour} /h     ')
        self.left_hour.setFont(self.litter_font)
        if deleta_hour < 1:
            self.left_hour.setStyleSheet("QLabel{color: #FF0000}")
        elif deleta_hour < 12:
            self.left_hour.setStyleSheet("QLabel{color: #2be360}")
        self.name_label = QLabel(_name)
        self.name_label.setFont(self.litter_font)
        self.pubdate_label = QLabel(_pub_date)
        self.pubdate_label.setFont(self.litter_font)
        self.info_layout.addWidget(self.left_label)
        self.info_layout.addWidget(self.left_hour)
        self.info_layout.addWidget(self.name_label)
        self.info_layout.addWidget(self.pubdate_label)
        
        self.main_layout.addWidget(self.title_label)
        self.main_layout.addLayout(self.info_layout)
        self.setLayout(self.main_layout)
        



if __name__ == '__main__':
    app = QApplication(sys.argv)
    _title = '这里是标题'
    _name = '这里是姓名'
    _time = '这里是日期'
    el = ElementWidget(_title,_name,_time)
    el.show()
    sys.exit(app.exec_())
        
        
        
        
        